package team.tinavv.ssheasy.sys.service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import team.tinavv.ssheasy.core.dao.BaseRepository;
import team.tinavv.ssheasy.core.service.CoreService;
import team.tinavv.ssheasy.model.SysUser;
import team.tinavv.ssheasy.sys.dao.SysUserDao;

@Service
public class SysUserService extends CoreService<SysUser, String> {

	@Autowired
	private SysUserDao sysUserDao;

	private static final Logger LOG = Logger.getLogger(SysUserService.class);

	@Override
	protected BaseRepository<SysUser, String> getDao() {
		return sysUserDao;
	}

	public void save() {
		SysUser user = new SysUser();
		user.setLoginname("sucess");
		user.setAge(12);
		user.setCreatedatetime(new Date());
		user.setId(UUID.randomUUID().toString());
		user.setPwd("sucess");
		user.setPhoto("18680480480");
		LOG.info("log4j");
		sysUserDao.save(user);
	}

	/**
	 * 根据用户名查询用户集合
	 * 
	 * @param name
	 * @return
	 */
	public List<SysUser> findByName(String name) {
		return sysUserDao.findByName(name);
	}

	/**
	 * 根据用户id查询用户年龄
	 * 
	 * @param id
	 * @return
	 */
	public List<Map<String, Object>> findAllUserBySql(String sql) {
		return sysUserDao.findAllUserBySql(sql);
	}
}
